charset="UTF-8"


Ext.onReady(function(){
Ext.QuickTips.init();
    var buttonRegist = Ext.get('regist');

    var addPatientForm = new Ext.FormPanel({
        labelAlign: 'top',
        frame:true,
        bodyStyle:'padding:5px 5px 0',
        width: 600,
        items:[
        	{layout:'column',border:false,labelSeparator:':',
             defaults:{layout: 'form',border:false,columnWidth:.33},
              items:[
                    {items: [{
                    	xtype:'textfield',
                    	vtype:'alphanum',
                   		allowBlank:false,
                    	blankText:'不能为空',
                    	minLength:4,
                    	minLengthText:'最小长度4',
                    	maxLength:30,
                    	maxLengthText:'最大长度30',
                    	fieldLabel: '身份证号码',
                    	id:'addidentify',
                    	name: 'identify',
                    	anchor:'90%'
                    	}]},
                    {
                    	columnWidth:.54,
                   		items: [{
						xtype:'textfield',
                   		allowBlank:false,
                    	blankText:'不能为空',
                    	maxLength:20,
                    	maxLengthText:'最大长度20',
                    	fieldLabel: '姓名',
                    	id:'addname',
                    	name: 'name',
                    	anchor:'50%'
                    	}]},
                    {items: [{
							inputType: 'password',
                			xtype:'textfield',
                    		allowBlank:false,
                    		blankText:'不能为空',
                    		minLength:4,
                    		minLengthText:'最小长度4',
                    		maxLength:20,
                    		maxLengthText:'最大长度20',
                    		fieldLabel: '密码',
                    		id: 'addpassword',
                    		name: 'password',
                    		anchor:'90%'
                    }]},
                    {items: [{
							inputType: 'password',
                			xtype:'textfield',
                    		vtype:'password',
                    		initialPassField: 'addpassword',
                    		allowBlank:false,
                    		blankText:'不能为空',
                    		fieldLabel: '重复密码',
                    		id:'addconfirmpassword',
                    		name: 'confirmpassword',
                    		anchor:'90%'
                    }]},
                    {items: [{
							xtype:'combo',  
                			fieldLabel:"性别",  
                			store:new Ext.data.JsonStore({  
                    		data:{data:[  
                                {id:"male",value:"男"},{id:"female",value:"女"}]},  
                    		root:"data",  
                    		fields:["id","value"]  
                			}),  
                			editable:false,
                			allowBlank:false,
                    		blankText:'不能为空',
                			emptyText:"请选择性别",
                			displayField:"value",  
                			hiddenName: "sex",
							valueField:"value",
                			mode:"local",    
                			triggerAction:"all",
                			anchor:'90%'
                	}]},
                    {items: [{
							xtype:'checkbox',
                    		fieldLabel: '婚姻状况',
                    		boxLabel:'已婚',
                    		id:'addmarry',
                    		name: 'marry',
                    		anchor:'90%'
                    }]},
                    {items: [{
							xtype:'datefield',
                    		fieldLabel: '出生日期',
                    		id:'addbirthday',
                    		name: 'birthday',
                    		allowBlank:false,
                    		blankText:'不能为空',
                    		emptyText:'请选择日期', 
                    		invalidText : "{0} 是无效的日期 - 必须符合格式： {1}", 
							format : "Y-m-d" ,
							maxValue:new Date(),  
          					maxText:'时间不能超过今天',  
                    		anchor:'90%'
                    		}]},
                    {items: [{
							xtype:'textfield',
                   			allowBlank:false,
                    		blankText:'不能为空',
                    		maxLength:50,
                    		maxLengthText:'最大长度50',
                    		fieldLabel: '出生地',
                    		id:'addbirthplace',
                    		name: 'birthplace',
                    		anchor:'90%'
                    }]},
                    {items: [{
							xtype:'textfield',
                    		allowBlank:false,
                    		blankText:'不能为空',
                    		maxLength:20,
                    		maxLengthText:'最大长度20',
                    		fieldLabel: '民族',
                    		id:'addMZ',
                    		name: 'MZ',
                    		anchor:'90%'
                    }]}, 
                    {items: [{
                    		xtype:'textfield',
                    		maxLength:10,
                    		maxLengthText:'最大长度10',
                    		fieldLabel: '血型',
                    		id:'addbloodtype',
                    		name: 'bloodtype',
                    		anchor:'90%'
                     }]},
                     {columnWidth:.9,
                     items: [{
                    		xtype:'textarea',
                    		maxLength:100,
                    		maxLengthText:'最大长度100',
                    		fieldLabel: '过敏史',
                    		id:'addGMS',
                    		name: 'GMS',
                    		anchor:'90%'
                     }]},
                     {columnWidth:.9,
                     items: [{
                    		xtype:'textarea',
                    		maxLength:100,
                    		maxLengthText:'最大长度100',
                    		fieldLabel: '家族史',
                    		id:'addJZS',
                    		name: 'JZS',
                    		anchor:'90%'
                     }]}
               ]}
               ],
		monitorValid:true,
        buttons: [{
            text: '注册',
            formBind: true,
            handler:function(){                   
            	addPatientForm.getForm().submit({//客户端的数据提交给服务器   
                     url:'registPublic.action',      
                     method:'post',
                     waitTitle: '信息', 
                    waitMsg:"正在提交，请稍候。。。",  
                    success: function(form, action){   
                         Ext.MessageBox.alert('信息', '注册成功，请登录');
                         winRegist.hide();
                      },
                     failure:function(form, action){  
                         Ext.MessageBox.alert('错误', '注册失败，请重试'); 

                     }                                  
                 }); 
                 
                }
        },{
            text: '取消',
            handler:function(){
					addPatientForm.form.reset();
					winRegist.hide();
                }
        }]
    });
    
        var winRegist = new Ext.Window({
                applyTo:'registWindow',
                layout:'fit',
                width:600,
                height:500,
                closeAction:'hide',
                plain: true,

                items: [addPatientForm]

               
            });


    buttonRegist.on('click', function(){
        winRegist.show(this);
    });
});


